<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.supplierNum" placeholder="供应商编号" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="dataForm.company" placeholder="公司名称" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="dataForm.loginId" placeholder="登录名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column type="expand" label="详情">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <el-form-item label="序号:">
              <span>{{ props.row.supplierNum }}</span>
            </el-form-item>
            <br>
            <el-form-item label="供应商证书编号:">
              <span>{{ props.row.certificate }}</span>
            </el-form-item>
            <br>
            <el-form-item label="公司名称:">
              <span>{{ props.row.company }}</span>
            </el-form-item>
            <br>
            <el-form-item label="公司性质:">
              <span>{{ props.row.kind }}</span>
            </el-form-item>
            <br>
            <el-form-item label="联系人:">
              <span>{{ props.row.contact }}</span>
            </el-form-item>
            <br>
            <el-form-item label="电话:">
              <span>{{ props.row.phone }}</span>
            </el-form-item>
            <br>
            <el-form-item label="传真:">
              <span>{{ props.row.fax }}</span>
            </el-form-item>
            <br>
            <el-form-item label="电子邮箱:">
              <span>{{ props.row.email }}</span>
            </el-form-item>
            <br>
            <el-form-item label="地址:">
              <span>{{ props.row.address }}</span>
            </el-form-item>
            <br>
            <el-form-item label="邮编:">
              <span>{{ props.row.zip }}</span>
            </el-form-item>
            <br>
            <el-form-item label="注册资金:">
              <span>{{ props.row.regFund }}</span>
            </el-form-item>
            <br>
            <el-form-item label="法人代表:">
              <span>{{ props.row.corporation }}</span>
            </el-form-item>
            <br>
            <el-form-item label="业绩:">
              <span>{{ props.row.achievement }}</span>
            </el-form-item>
            <br>
            <br>
          </el-form>
        </template>
      </el-table-column>

      <el-table-column
        type="index"
        header-align="center"
        align="center"
        label="序号">
      </el-table-column>
      <el-table-column
        prop="supplierNum"
        header-align="center"
        align="center"
        label="供应商编号">
      </el-table-column>
      <el-table-column
        prop="company"
        header-align="center"
        align="center"
        label="公司名称">
      </el-table-column>
      <el-table-column
        prop="usersEntity.loginId"
        header-align="center"
        align="center"
        label="登录名">
      </el-table-column>
      <el-table-column
        prop="achievement"
        header-align="center"
        align="center"
        label="业绩列表">
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[5, 10, 20, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        dataForm: {
          index:1,
          supplierNum: '',
          company:'',
          loginId:''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
      }
    },
    mounted () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/purchase/supplier/supplierList'),
          method: 'get',
          params:{
            page:this.pageIndex,
            limit:this.pageSize,
            supplierNum:this.dataForm.supplierNum,
            company:this.dataForm.company,
            loginId:this.dataForm.loginId,
          }
        }).then((data) => {
          if (data && data.code === 200) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
            console.log("参数名",data)
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
    }
  }
</script>
